using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class DeleteRowMethodPage : System.Web.UI.Page
{
    SqlDataSource sqlDataSource;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            FillRecruiterAccount(GridView1);
    }

    void FillRecruiterAccount(GridView gridView)
    {
        sqlDataSource = new SqlDataSource();
        sqlDataSource.ConnectionString =
        WebConfigurationManager.ConnectionStrings[
            "RecruitVietnamDbConnectionString"
            ].ConnectionString;
        sqlDataSource.SelectCommandType =
        SqlDataSourceCommandType.Text;
        sqlDataSource.SelectCommand = "select " +
        "Email,CompanyName, ContactName,"
        + "Address,Activate from tblRCAccounts";
        gridView.DataSource = sqlDataSource;
        gridView.DataBind();

    }


    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        FillRecruiterAccount(GridView1);
    }

   
    protected void Button1_Click(object sender, EventArgs e)
    {
        for (int i=0;i< GridView1.Rows.Count;i++ )
        {
            CheckBox checkBox = (CheckBox)GridView1.Rows[i].Cells[4].Controls[0];

            if (checkBox != null && !checkBox.Checked)
            {
                GridView1.DeleteRow(i);
            }            
        }
         
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
}
